home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
BUTTEST.ZIP
/
GRAPHBUT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-01-31
|
4KB
|
112 lines
Program Button_Test;
Uses
Crt,Graph,Mouse,Button3,Cursors;
Var
GMouse : GraphicMouse;
TMouse : TextMouse; {Only for reinitializing at end of program}
mButton : position;
GButton : array[1..10] of Button;
Exit,Status : boolean;
Gdriver,Gmode,Gerror,I,J,SButtons,BtnCount : integer;
{*************************************************************************}
Procedure Init_Buttons;
Var
I : integer;
TempStr : string[2];
Begin
for I := 1 to 5 do
with GButton[I] do
begin
Str(I:2,TempStr);
Init;
SetButtonType(Rounded);
Create((I-1)*110+10,(I-1)*50+10,100,40,I+8,' Test'+TempStr);
end;
GButton[6].Init;
GButton[6].SetButtonType(ThreeD);
GButton[6].Create(10,260,100,40,White,'Quit');
GButton[7].Init;
GButton[7].SetButtonType(ThreeD);
GButton[7].Create(0,400,100,40,Blue,'SWORD');
GButton[8].Init;
GButton[8].SetButtonType(ThreeD);
GButton[8].Create(GetMaxX div 4,400,100,40,Blue,'GLOVE');
GButton[9].Init;
GButton[9].SetButtonType(ThreeD);
GButton[9].Create(GetMaxX div 2,400,100,40,Blue,'CHECK');
GButton[10].Init;
GButton[10].SetButtonType(ThreeD);
GButton[10].Create(GetMaxX*3 div 4,400,100,40,Blue,'HAMMER');
End;
{*************************************************************************}
BEGIN
Gdriver := detect;
InitGraph(Gdriver,Gmode,'f:\bgi');
Gerror := GraphResult;
if Gerror <> GrOk then
begin
Writeln('Graphics Error: ',GraphErrorMsg(Gerror));
Writeln('Program Aborted....');
Halt(1);
end;
ClearDevice;
Init_Buttons;
GMouse.Reset(Status,BtnCount);
Exit := False;
for I := 1 to 10 do
GButton[I].Init;
if Status then {we have a mouse!}
begin
GMouse.Initialize;
GMouse.SetCursor(ARROW);
Repeat
GMouse.QueryBtnDn(ButtonL,mButton);
if mButton.OpCount > 0 then
begin
GMouse.Show(False);
for I := 1 to 10 do
if (GButton[I].State) then
GButton[I].Invert;
for I := 1 to 10 do
if GButton[I].ButtonHit(mButton.Xpos,
mButton.Ypos) then
begin
GMouse.Show(True);
Sound(I*220);
Delay(100);
NoSound;
Delay(100);
Sound(I*110);
Delay(100);
NoSound;
if I = 6 then
Exit := True;
if I = 7 then
GMouse.SetCursor(SWORD);
if I = 8 then
GMouse.SetCursor(GLOVE);
if I = 9 then
GMouse.SetCursor(CHECK);
if I = 10 then
GMouse.SetCursor(HAMMER);
end;
GMouse.Show(True);
end;
Until Exit;
end;
CloseGraph;
TMouse.Initialize; {Reset text mouse cursor}
ClrScr;
END.